/**
 * 匠言知识付费v2.0.0
 * Author: 山西匠言网络科技有限公司
 * 这不是一个免费软件，它受限于许可条款，你可以访问https://www.zsfzxkc.cn/获取更多详细信息。
 * This is not a free software, it under the license terms, you can visit https://www.zsffzxkc.cn/ get more details.
 */
<template>
	<view class="container">
		<jy-quick-btns></jy-quick-btns>
		<view class="message-details" v-if="type=='sys'">
			<view class="message-details-list" v-for="(item, index) in msgList" :key="index" @click="detail(item,item.id,'sys')">
				<view class="item-left">
					<text>{{item.addtime}}</text>
				</view>
				<view class="item-right">
					<text>{{item.title}}</text>
					<view v-html="item.name"></view>
				</view>
			</view>
		</view>
		<view class="message-details" v-if="type=='my'">
			<view class="message-details-list" v-for="(item, index) in msgList" :key="index" @click="detail(item,item.id,'my')">
				<view class="item-left">
					<text>{{item.send_time}}</text>
				</view>
				<view class="item-right">
					<text>{{item.title}}</text>
					<view v-html="item.content"></view>
				</view>
			</view>
		</view>
		
		<view class="wuxiaoxi" v-if="msgList.length === 0">
			<image src="../../static/wuxiaoxi.jpg" mode="aspectFit"></image>
		</view>
		
	</view>
</template>

<script>
	import { postNewnotice } from '@/request/message'
	export default {
		data() {
			return {
				msgList: [],
				type:''
			};
		},
		onLoad(e) {
			this.type = e.type
			let type = e.type
			if(type == 'sys'){
				postNewnotice().then(res => {
					console.log(res.data)
					this.msgList = res.data.data
				})
			}else{
				this.msgList = getApp().globalData.new_msgList;
			}
		},
		methods:{
			detail(item,id,type){
				if(type == 'my'){
					uni.showToast({
						title:'朕已读'
					})
				}else{
					uni.navigateTo({
						url:'../notice-detail/notice-detail?id='+id+'&item = '+ JSON.stringify(item)+'&type ='+type
					})
				}
				if(getApp().globalData.dot_text>=1){
					getApp().globalData.dot_text--;
				}
			}
		}
	}
</script>

<style lang="less" scoped>

.message-details {
	&-list {
		overflow: hidden;
		margin: 10upx;
		padding: 10upx;
		background-color: #fff;
		display: flex;
		.item-left {
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 30%;
			text:nth-child(1) {
				font-size: 32upx;
				font-weight: 700;
				color: #333;
			}
			text:nth-child(2), text:nth-child(3) {
				font-size: 26upx;
				color: #999;
			}
		}
		.item-right {
			width: 70%;
			display: flex;
			flex-direction: column;
			text:nth-child(1) {
				font-size: 34upx;
				font-weight: 700;
				color: #333;
			}
			text:nth-child(2) {
				font-size: 30upx;
				color: #999;
				margin-top: 10upx;
			}
		}
	}
}

.wuxiaoxi {
	width: 100%;
	height: 100%;
	background-color: #fff;
	position: fixed;
	top: 0;
	left: 0;
	image {
		width: 100%;
		height: 100%;
	}
}

</style>
